<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>{$Think.config.app_name}-后台管理</title>

	{include file="public:head" /}
	<style>
		body {
			height: 100vh;
			background: url(/static/admin/background.jpg) no-repeat center center;
		}
		.login-container { padding: 120px 0; box-sizing: border-box; }
		.login-container>div { margin: 0 auto; box-sizing: border-box; width: 375px; }
		.login-container .login-header { text-align: center; padding: 20px; color: #000; }
		.login-container .login-main { padding: 20px; }
		.login-container .layui-form-item { position: relative; }
		.login-container .login-icon { position: absolute; left: 1px; top: 1px; width: 38px; line-height: 36px; text-align: center; color: #d2d2d2; z-index: 9; }
		.login-container .layui-input { padding-left: 38px; }
		.login-container .login-footer { text-align: center; }
		.sliderContainer { width: 100%; }
		.code { height: 36px; width: 123px; cursor: pointer; border: 1px solid #e6e6e6; position: relative; top: -8px; left: 9px; }
		.code img { width: 100%; height: 100%;  }
	</style>
</head>
<body>
	<div class="login-container">
		<div class="login-header">
			<h2>{$Think.config.app_name}后台管理</h2>
		</div>
		<div class="login-main layui-form">
			<div class="layui-form-item">
				<label class="login-icon layui-icon layui-icon-username"></label>
				<input autocomplete="off" name="login_user" lay-verify="required" placeholder="用户名" class="layui-input" type="text">
			</div>
			<div class="layui-form-item">
				<label class="login-icon layui-icon layui-icon-password"></label>
				<input autocomplete="off" name="login_pass" lay-verify="required" placeholder="用户密码" class="layui-input" type="password">
			</div>
			<div class="layui-form-item">
				<label class="login-icon layui-icon layui-icon-vercode"></label>
				<div class="layui-input-inline">
					<input autocomplete="off" type="text" name="code" required lay-verify="required" placeholder="请输入验证码" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux">
					<div class="code">
						<img id="imgcode" src="{:captcha_src()}" onclick="refreshVerify()" />
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<button class="layui-btn layui-btn-fluid" id="login-btn" lay-submit lay-filter="login-btn">登 入</button>
			</div>
		</div>

		<div class="login-footer">
			<p>{$Think.config.app_name}版权所有 © 2020 </p>
		</div>
	</div>

	<script>
		layui.use('form', function() {
			var form = layui.form

			// 事件监听
			form.on('submit(login-btn)', function(data) {
				var d = data.field

				_671.post('{:url("index")}', d, function(res) {
					if (res.code === 200) {
						layer.msg('登录成功，正在跳转...', { icon: 6, time: 1500 }, function() {
							window.location.href = '{:url("/publics/index/index")}'
						})
					} else {
						layer.msg(res.msg, { icon: 5, time: 1500 })
						refreshVerify()
					}
				})
			})
		})

		// 回车键绑定提交
		$(document).bind('keyup', function(e) {
			if (e.keyCode === 13) {
				$('#login-btn').trigger("click")
			}
		})

		// 刷新验证码
		var refreshVerify = function() {
			var ts = Date.parse(new Date()) / 1000
			$("#imgcode").attr('src', '/captcha?rand=' + ts);
		}
	</script>
</body>
</html>
